package com.xsoft.sms.utils;


import java.io.File;

/**
 * package: {PACKAGE_NAME}
 * User: zhanglm
 * Date: 12-9-17
 * Time: 下午11:36
 * Description:
 */
public class Helpers {

	public static String hexToString(byte[] data) {
		String DEFAULT_SPLITER = "";
		return hexToString(data, DEFAULT_SPLITER);
	}

	public static String hexToString(byte[] data, String spliter) {
		StringBuilder sb = new StringBuilder();
		for (byte aData : data) {
			sb.append(Integer.toHexString(aData));
			sb.append(spliter);
		}
		return sb.toString();
	}

	public static String getRuntimePath() {
		String fullPath =  Helpers.class.getProtectionDomain().getCodeSource().getLocation().getPath();
		int firstIndex = fullPath.lastIndexOf(System.getProperty("path.separator"))+1;
		int lastIndex = fullPath.lastIndexOf(File.separator) +1;
		return fullPath.substring(firstIndex, lastIndex);
	}
}
